import {
	loginApi
} from '@/api/login.js'

export const userInfoMixin = {
	data() {
		return {
			userInfo: {},
		}
	},
	methods: {
		async getUserInfoByLogin() {
			const res = await loginApi()
			if (res) {
				this.userInfo = res.data.data
			}
		},
		userInfo_init() {
			if (this.userInfo.id) return
			const userInfo = uni.getStorageSync('userInfo')
			this.userInfo = userInfo
			if (!userInfo.id) {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			}
		}
	}
}